﻿using MathNet.Numerics.LinearAlgebra;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace FittyWars.BordUtils
{
    public class CrashSpace
    {
        public Polygon BoundingBox { get; set; }
        public double Radious { get; set; }

        public bool OnlyCircularBox { get; private set; }

        public CrashSpace(Polygon p)
        {
            BoundingBox = p;
            OnlyCircularBox = false;
            Radious = p.Vectors.Max(v => Math.Sqrt(v[0] * v[0] + v[1] * v[1]));
        }
        public CrashSpace(double radious)
        {
            Radious = radious;
            OnlyCircularBox = true;
            BoundingBox = null;
        }

        /*public static bool CheckSingleCrash(CrashSpace c1, CrashSpace c2)
        {
            double dist = c1.Center.Distance(c2.Center);
            if (dist > c1.ContainingCircle.Radious + c2.ContainingCircle.Radious)
            {
                return false;
            }
            if (c1.OnlyCircularBox)
            {
                if (c2.OnlyCircularBox)
                {
                    return (c1.ContainingCircle.Radious < dist && dist < c2.ContainingCircle.Radious) ||
                           (c2.ContainingCircle.Radious < dist && dist < c1.ContainingCircle.Radious);
                }
                else
                {
                    return CirclePolyIntersection(c1, c2);
                }
            }
            else
            {
                if (c2.OnlyCircularBox)
                {
                    return CirclePolyIntersection(c2, c1);
                }
            }
            return PolyIntersection(c1, c2);
        }*/

        private static bool CirclePolyIntersection(CrashSpace circSpace, CrashSpace polySpace)
        {
            return true;
        }

        private static bool PolyIntersection(CrashSpace c1, CrashSpace c2)
        {
            return true;
        }
    }
}
